package com.boruiimage.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.boruiimage.demo.doMain.ResultModel;
import com.boruiimage.demo.doMain.ResultTools;
import com.boruiimage.demo.doMain.memberuser;
import com.boruiimage.demo.doMain.recharacterinfo;
import com.boruiimage.demo.repository.registerMemberUserDao;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class vipUserInfo {
    @Autowired
    registerMemberUserDao rmud;
    @RequestMapping(value = "/selectVipInfo")
    public ResultModel login(@RequestBody Map<String, String> postMap){
        try {
            String username = postMap.get("userName");
            List<memberuser> vipInfoList =rmud.listMemberuser(username);
            Map<String, Object> map = new HashMap<>();
            map.put("data", vipInfoList);
            return ResultTools.result(0, "成功", map);
        }catch (Exception e){
            return ResultTools.result(404, e.getMessage(), null);
        }
    }

    @RequestMapping("/selRecharVipInfo")
    public ResultModel selRecharVipInfo(@RequestBody Map<String,String>map){
       try {
           int page=(Integer.parseInt(map.get("pageNum"))-1)*15;
           PageHelper.startPage(page,15);
           List<recharacterinfo> list=rmud.selByrecharacterinfo(map.get("userName"));
           Map<String,Object> maps=new HashMap<>();
           maps.put("data",list);
           return ResultTools.result(0,"成功",maps);
       }catch (Exception e){
           return ResultTools.result(1,"失败",null);
       }
    }
}
